package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.LocalAccessAdressDetailAttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import com.iwhalecloud.bss.kite.service.scene.attr.OperateInstAttrService;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * @author LIFF
 * @version 2022/2/28 11:52
 * Description: 云联网专线接入产品-新版--接入地址：标准地址补充说明
 */
@Service
@AttrHandler(LocalAccessAdressDetailAttrHandler.class)
public class LocalAccessAdressDetailAttrLinkHandler extends AbstractAttrLinkageHandler<AttrData> {

    @Resource
    private OperateInstAttrService operateInstAttrService;

    @Override
    public void handle(KiteAttr kiteAttr, KiteInst kiteInst, AttrData attrData) {
        KiteAttr addressDetailAttr = kiteInst.getAttr("2_0000211");
        StringBuffer addressDetail = new StringBuffer();
        if(KiteStringUtils.isNotEmpty(addressDetailAttr.getValue())){
            addressDetail.append(addressDetailAttr.getValue());
            addressDetail.append("-");
        }
        addressDetail.append(kiteAttr.getValue());
        operateInstAttrService.setAttrValue(kiteInst, "200001752", addressDetail.toString(), attrData.getSceneInstId(), null);
    }

    @Override
    public void handleStyle(KiteAttr kiteAttr, KiteInst kiteInst, AttrData attrData) {

    }
}
